package ynu.edu.elmspringboot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ynu.edu.elmspringboot.po.Business;
import ynu.edu.elmspringboot.service.BusinessService;

import java.util.List;

@RestController
@RequestMapping("/BusinessController")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @PostMapping("/listBusinessByOrderTypeId")
    public List<Business> listBusinessByOrderTypeId(Business business) {
//        return businessService.listBusinessByOrderTypeId(business.getOrderTypeId());
        return businessService.list(new QueryWrapper<Business>().eq("order_type_id", business.getOrderTypeId()));
    }

    @PostMapping("/getBusinessById")
    public Business getBusinessById( Integer businessId) {
        return businessService.getById(businessId);
    }
}